package com.learn.demo.dao;

import com.learn.demo.model.t_user;
import com.learn.demo.model.t_userExample;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import java.util.List;

public class t_userDAOImpl extends SqlMapClientDaoSupport implements t_userDAO {

    public t_userDAOImpl() {
        super();
    }

    public long countByExample(t_userExample example) {
        Long count = (Long)  getSqlMapClientTemplate().queryForObject("t_user.countByExample", example);
        return count;
    }

    public int deleteByExample(t_userExample example) {
        int rows = getSqlMapClientTemplate().delete("t_user.deleteByExample", example);
        return rows;
    }

    public int deleteByPrimaryKey(Integer id) {
        t_user _key = new t_user();
        _key.setId(id);
        int rows = getSqlMapClientTemplate().delete("t_user.deleteByPrimaryKey", _key);
        return rows;
    }

    public void insert(t_user record) {
        getSqlMapClientTemplate().insert("t_user.insert", record);
    }

    public void insertSelective(t_user record) {
        getSqlMapClientTemplate().insert("t_user.insertSelective", record);
    }

    @SuppressWarnings("unchecked")
    public List<t_user> selectByExample(t_userExample example) {
        List<t_user> list = getSqlMapClientTemplate().queryForList("t_user.selectByExample", example);
        return list;
    }

    public t_user selectByPrimaryKey(Integer id) {
        t_user _key = new t_user();
        _key.setId(id);
        t_user record = (t_user) getSqlMapClientTemplate().queryForObject("t_user.selectByPrimaryKey", _key);
        return record;
    }

    public int updateByExampleSelective(t_user record, t_userExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("t_user.updateByExampleSelective", parms);
        return rows;
    }

    public int updateByExample(t_user record, t_userExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("t_user.updateByExample", parms);
        return rows;
    }

    public int updateByPrimaryKeySelective(t_user record) {
        int rows = getSqlMapClientTemplate().update("t_user.updateByPrimaryKeySelective", record);
        return rows;
    }

    public int updateByPrimaryKey(t_user record) {
        int rows = getSqlMapClientTemplate().update("t_user.updateByPrimaryKey", record);
        return rows;
    }

    protected static class UpdateByExampleParms extends t_userExample {
        private Object record;

        public UpdateByExampleParms(Object record, t_userExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}